package mo.offer_version2;

import mo.common.ListNode;

public class L24 {

    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode cur = head;
        ListNode next = head.next;
        cur.next = null;
        while (next.next != null) {
            ListNode tmp = next.next;
            next.next = cur;
            cur = next;
            next = tmp;
        }
        next.next = cur;
        return next;
    }

}
